package br.ufc.minijavaufc.semantic;

import java.util.Hashtable;

public class Symbol {
	private String name;
	private static Hashtable<String, Symbol> dictionary = new Hashtable<String, Symbol>();

	private Symbol(String nome) {
		name = nome;
	}

	public static Symbol symbol(String nome) {
		String internName = nome.intern();
		Symbol symbol = (Symbol) dictionary.get(internName);
		if (symbol == null) {
			symbol = new Symbol(internName);
			dictionary.put(internName, symbol);
		}
		return symbol;
	}

	@Override
	public String toString() {
		return name;
	}
}